Math (math)

Number-theoretic and representation functions

absolute

Return the absolute value of x.

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.absolute","math.absolute":"absolute","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"x":-7.25},"height":32,"width":120,"step":"get absolute of -7.25","data_to_var":"abs","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"abs":3.141592653589793}

ceil

Return the ceiling of x as a float, the smallest integer value greater than or equal to x.

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.ceil","math.ceil":"ceil","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"x":1.4},"height":32,"width":120,"step":"get ceil of 1.4","data_to_var":"ceil","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"ceil":2}

factorial

Return x factorial. Raises error if x is not integral or is negative.

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.factorial","math.factorial":"factorial","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"x":5},"height":32,"width":120,"step":"get factorial of 5","data_to_var":"f","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"f":3.12}

floor

Return the floor of x as a float, the largest integer value less than or equal to x.

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.floor","math.floor":"floor","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"x":1.6},"height":32,"width":120,"step":"get floor of 1.6","data_to_var":"floored","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"floored":3.141592653589793}

fmod

The intent of the C standard is that fmod(x, y) be exactly (mathematically; to infinite precision) equal to x - n*y for some integer n such that the result has the same sign as x and magnitude less than abs(y).

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.fmod","math.fmod":"fmod","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"x":5,"y":2},"height":32,"width":120,"step":"get fmod of 5.0, 2.0","data_to_var":"fmod","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"fmod":1}

frexp

Return the mantissa and exponent of x as the pair (m, e). m is a float and e is an integer such that x == m * 2**e exactly. If x is zero, returns (0.0, 0), otherwise 0.5 <= abs(m) < 1. This is used to "pick apart" the internal representation of a float in a portable way.

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.frexp","math.frexp":"frexp","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"x":4},"height":32,"width":120,"step":"get frexp of 4.0","data_to_var":"frexp","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"frexp":{"mantissa":0.5,"exp":3}}

fsum

Return an accurate floating point sum of values in the iterable. Avoids loss of precision by tracking multiple intermediate partial sums.

The algorithm’s accuracy depends on IEEE-754 arithmetic guarantees and the typical case where the rounding mode is half-even. On some non-Windows builds, the underlying C library uses extended precision addition and may occasionally double-round an intermediate sum causing it to be off in its least significant bit.

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.fsum","math.fsum":"fsum","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"list":[0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1]},"height":32,"width":120,"step":"get fsum of list","data_to_var":"fsum","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"fsum":1}

isinf

Check if the float x is positive or negative infinity.

 

{ }
[{"paths":["071651f79538c5be3173b651cc9bcb7e"],"data":{"math":"math","call":"math.constants.inf","math.constants.inf":"inf","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{},"height":32,"width":120,"step":"e","data_to_var":"inf","y":0,"x":0,"type":"library","maxpaths":1}},{"paths":[],"data":{"math":"math","call":"math.isinf","math.isinf":"isinf","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"x":"{\"~\":\"inf\"}"},"height":32,"width":120,"step":"get isinf of inf","data_to_var":"isinf","y":80,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"isinf":true}

isnan

Check if the float x is a NaN (not a number). For more information on NaNs, see the IEEE 754 standards.

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.isnan","math.isnan":"isnan","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"x":"x"},"height":32,"width":120,"step":"get isnan of 'x'","data_to_var":"isnan","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"isnan":true}

ldexp

Return x * (2**i). This is essentially the inverse of function frexp().

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.ldexp","math.ldexp":"ldexp","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"x":0.8,"i":-3},"height":32,"width":120,"step":"get ldexp of 0.80, -3","data_to_var":"ldexp","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"ldexp":0.1}

min

Get the smallest value in the list provided.

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.min","math.min":"min","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"list":[1,2,3,9,8,7,6,5]},"height":32,"width":120,"step":"get min of list","data_to_var":"min","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"min":1}

max

Get the largest value in the list provided.

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.max","math.max":"max","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"list":[1,2,3,9,8,7,6,5]},"height":32,"width":120,"step":"get max of list","data_to_var":"max","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"max":9}

modf

Return the fractional and integer parts of x. Both results carry the sign of x and are floats.

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.modf","math.modf":"modf","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"x":7.25},"height":32,"width":120,"step":"get modf of 7.25","data_to_var":"modf","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"modf":{"integer":7,"fractional":0.25}}

neg

Return the negative of x (-x).

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.neg","math.neg":"neg","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"x":7.25},"height":32,"width":120,"step":"get neg of 7.25","data_to_var":"neg","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"neg":-7.25}

pos

Return the positive of x (+x).

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.pos","math.pos":"pos","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"x":-7.25},"height":32,"width":120,"step":"get pos of -7.25","data_to_var":"pos","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"pos":7.25}

round

Return the floating point value number rounded to ndigits digits after the decimal point. If ndigits is omitted, it defaults to zero. The result is a floating point number. Values are rounded to the closest multiple of 10 to the power minus ndigits; if two multiples are equally close, rounding is done away from 0 (so, for example, round(0.5) is 1.0 and round(-0.5) is -1.0).

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.round","math.round":"round","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"number":1.2345678,"digits":2},"height":32,"width":120,"step":"get rounded number","data_to_var":"rounded","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"rounded":1.24}

trunc

Return the Real value x truncated to an Integral (usually a long integer).

 

{ }
[{"paths":[],"data":{"math":"math","call":"math.trunc","math.trunc":"trunc","uuid":"071651f79538c5be3173b651cc9bcb7e","args":{"x":-7.25},"height":32,"width":120,"step":"get trunc of -7.25","data_to_var":"trunc","y":0,"x":0,"type":"library","maxpaths":1}}]

Example Response

{"trunc":-7}